package com.learn.training.multithread.chapter6.minchapter1.demo5;

public class Counter {
    private int count = 0;

    public void add(int n) {
        synchronized (this) {
            System.out.println("add : " + Thread.currentThread().getName() + " : " +this.toString());
            count += n;
        }
    }

    public void dec(int n){
        synchronized (this) {
            System.out.println("dec : " + Thread.currentThread().getName() + " : " + this.toString());
            count -= n;
        }
    }

    public int get() {
        return count;
    }
}
